<%--
  Created by IntelliJ IDEA.
  User: dcd
  Date: 2018/11/13
  Time: 11:12 AM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/taglibs.jspf" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="decorator" content="list"/>
</head>
<body>
<form id="inReceiveForm" onkeydown="if(event.keyCode==13){return false;}">
    <input type="text" name="reqReceiveUserName" id="reqReceiveUserName" onkeydown="getName(event,this)"
           placeholder="请扫描接收者工号"
           style="width: 150px;height:40px;">
    <input type="hidden" name="reqReceiveUser" id="reqReceiveUser">
    <input type="text" name="requisitionNo" id="requisitionNo" placeholder="请扫描申请单号" onkeydown="getRequisition(event)"
           style="width: 150px;height:40px;">
</form>
<div class="layui-tab layui-tab-card layui-col-md12 layui-col-sm12" lay-filter="test">
    <ul class="layui-tab-title">
        <li class="layui-this">已接收</li>
        <li>未送达</li>
        <li>已申请</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <grid:grid id="receiveGrid" url="${appPath}/preProcessing/inReceive/getList" queryGroup="3" customHeight="50">
                <grid:column label="preProcessing:inReceive:reqReceiveTime" name="reqReceiveTime" query="true"
                             queryMode="date"
                             condition="between" dateformat="yyyy-MM-dd hh:mm" query_showDateFmt="yy/MM/dd"
                             queryValue="${queryValue}"/>
                <grid:column label="sys.application.number" name="requisitionNo" query="true" width="100"/>
                <grid:column label="sys.patient.name" name="reqPatientName" query="true" width="80"/>
                <grid:column label="sys:patient:number" name="reqPatientNumber" width="80"/>
                <grid:column label="patinet.hospital.way" name="reqPatientType" width="80"/>
                <grid:column label="sys.patient.ward" name="reqWardName" width="80"/>
                <grid:column label="sys.patient.bed.no" name="reqBedNum" width="60"/>
                <grid:column label="sys.patient.age" name="reqPatientAge" width="60"/>
                <grid:column label="sys.patient.sex" name="reqPatientSex" width="60"/>
                <grid:column label="apply.inspection.project" name="reqItemNames" width="130"/>
                <grid:column label="inspection.materials" name="reqSendMaterial" width="120"/>
                <grid:column label="preProcessing:inReceive:sampleNum" name="sampleNum" width="60"/>
                <grid:column label="apply.label.barcode" name="reqSampleId" width="100"/>
                <grid:column label="apply.inspection.hospital" name="reqReceiveOrgId" width="100"/>
                <grid:column label="apply.inspection.department" name="reqDeptName" width="100"/>
                <grid:column label="apply.inspection.doctor" name="reqDoctorName" width="80"/>
                <grid:column label="" name="reqState" query="true" hidden="true" queryMode="hidden" queryValue="2||gt"/>
                <grid:toolbar function="search"/>
            </grid:grid>
        </div>
        <div class="layui-tab-item">
            <grid:grid id="undeliveredGrid" url="${appPath}/preProcessing/inReceive/getList" queryGroup="3" customHeight="50">
                <grid:column label="sys.application.date" name="reqDate" query="true" queryMode="date"
                             condition="between" dateformat="yyyy-MM-dd hh:mm" query_showDateFmt="yy/MM/dd"
                             queryValue="${queryValue}"/>
                <grid:column label="sys.application.number" name="requisitionNo" query="true" width="100"/>
                <grid:column label="sys.patient.name" name="reqPatientName" query="true" width="80"/>
                <grid:column label="sys:patient:number" name="reqPatientNumber" width="80"/>
                <grid:column label="patinet.hospital.way" name="reqPatientType" width="80"/>
                <grid:column label="sys.patient.ward" name="reqWardName" width="80"/>
                <grid:column label="sys.patient.bed.no" name="reqBedNum" width="60"/>
                <grid:column label="sys.patient.age" name="reqPatientAge" width="60"/>
                <grid:column label="sys.patient.sex" name="reqPatientSex" width="60"/>
                <grid:column label="apply.inspection.project" name="reqItemNames" width="130"/>
                <grid:column label="inspection.materials" name="reqSendMaterial" width="120"/>
                <grid:column label="preProcessing:inReceive:sampleNum" name="sampleNum" width="60"/>
                <grid:column label="apply.label.barcode" name="reqSampleId" width="100"/>
                <grid:column label="apply.inspection.hospital" name="reqReceiveOrgId" width="100"/>
                <grid:column label="apply.inspection.department" name="reqDeptName" width="100"/>
                <grid:column label="apply.inspection.doctor" name="reqDoctorName" width="80"/>
                <grid:column label="" name="reqState" query="true" hidden="true" queryMode="hidden" queryValue="1"/>
                <grid:toolbar function="search"/>
            </grid:grid>
        </div>
        <div class="layui-tab-item">
            <grid:grid id="requisitionGrid" url="${appPath}/preProcessing/inReceive/getList" queryGroup="3" customHeight="50">
                <grid:column label="sys.common.sign" name="reqSign"/>
                <grid:column label="sys.application.date" name="reqDate" query="true" queryMode="date"
                             condition="between" dateformat="yyyy-MM-dd hh:mm" query_showDateFmt="yy/MM/dd"
                             queryValue="${queryValue}"/>
                <grid:column label="sys.application.number" name="requisitionNo" query="true" width="100"/>
                <grid:column label="sys.patient.name" name="reqPatientName" query="true" width="80"/>
                <grid:column label="sys:patient:number" name="reqPatientNumber" width="80"/>
                <grid:column label="patinet.hospital.way" name="reqPatientType" width="80"/>
                <grid:column label="sys.patient.ward" name="reqWardName" width="80"/>
                <grid:column label="sys.patient.bed.no" name="reqBedNum" width="60"/>
                <grid:column label="sys.patient.age" name="reqPatientAge" width="60"/>
                <grid:column label="sys.patient.sex" name="reqPatientSex" width="60"/>
                <grid:column label="apply.inspection.project" name="reqItemNames" width="130"/>
                <grid:column label="inspection.materials" name="reqSendMaterial" width="120"/>
                <grid:column label="preProcessing:inReceive:sampleNum" name="sampleNum" width="60"/>
                <grid:column label="apply.label.barcode" name="reqSampleId" width="100"/>
                <grid:column label="apply.inspection.hospital" name="reqReceiveOrgId" width="100"/>
                <grid:column label="apply.inspection.department" name="reqDeptName" width="100"/>
                <grid:column label="apply.inspection.doctor" name="reqDoctorName" width="80"/>
                <grid:column label="" name="reqState" query="true" hidden="true" queryMode="hidden" queryValue="0"/>
                <grid:toolbar function="search"/>
            </grid:grid>
        </div>
    </div>
</div>
<script>
    layui.use('element', function () {
        var element = layui.element;
        //获取hash来切换选项卡，假设当前地址的hash为lay-id对应的值
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);
        //监听Tab切换，以改变地址hash值
        element.on('tab(test)', function () {
            $("#receiveGridGrid").setGridWidth($(window).width() * 0.965);
            $("#undeliveredGridGrid").setGridWidth($(window).width() * 0.965);
            $("#requisitionGridGrid").setGridWidth($(window).width() * 0.965);
        });

    });

    function getName(e, obj) {
        if (e.keyCode == 13) {
            $.post(${appPath}'/preProcessing/inReceive/getName', {code: $(obj).val()}, function (data) {
                if (data.ret != -1) {
                    $('#reqReceiveUser').val($(obj).val());
                    $(obj).val(data.extend.name);
                    $('#requisitionNo').focus();
                } else {
                    top.layer.alert(data.msg, {icon: 0, title: '错误'});
                }
            })
        }
    }

    function getRequisition(e) {
        if (e.keyCode == 13) {
            var reqReceiveUser = $('#reqReceiveUser').val();
            var requisitionNo = $('#requisitionNo').val();
            if (reqReceiveUser == '') {
                top.layer.alert('请先扫描工号', {icon: 0, title: '警告'});
                return
            }
            if (requisitionNo == '') {
                top.layer.alert('请先扫描申请单号', {icon: 0, title: '警告'});
                return
            }
            $.post(${appPath}'/preProcessing/inReceive/getRequisition', {requisitionNo: requisitionNo}, function (data) {
                if (data.ret != -1) {
                    top.layer.closeAll();
                    top.layer.open({
                        type: 2,
                        area: ["800px", "500px"],
                        title: "申请信息-院内",
                        maxmin: true, //开启最大化最小化按钮
                        shade: 0.8,
                        content: "/preProcessing/inReceive/" + data.extend.id + "/update",
                        btn: ['确认接收'],
                        yes: function (index, layero) {
                            if (layerCallBack()) {
                                $.post('${appPath}/preProcessing/inReceive/receive', $('#inReceiveForm').serialize(), function (data) {
                                    if (data.ret != -1) {
                                        top.layer.alert(data.msg, {icon: 1});
                                        layer.close(index);
                                        //清空数据
                                        $('#reqReceiveUser').val('');
                                        $('#reqReceiveUserName').val('');
                                        $('#requisitionNo').val('');
                                        refreshTable('receiveGridGrid');
                                        refreshTable('undeliveredGridGrid');
                                        refreshTable('requisitionGridGrid');
                                    } else {
                                        top.layer.alert(data.msg, {icon: 0, title: '错误'});
                                    }
                                })
                            }
                        }
                    })
                } else {
                    top.layer.alert(data.msg, {icon: 0, title: '错误'});
                }
            })
        }
    }
</script>
</body>
</html>
